//
//  LeadPageViewController.swift
//  JLsmallDay
//
//  Created by sun on 16/1/4.
//  Copyright © 2016年 sun. All rights reserved.
//

import UIKit
import SnapKit
class LeadPageViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    init(){
        
        super.init(nibName: nil, bundle: nil)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setupUI(){
        view.addSubview(backgroundImage)
        view.addSubview(startBtn)
        
        startBtn.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(view.snp_centerX)
            make.top.equalTo(view.bounds.height * 0.8)
            make.width.equalTo(210)
            make.height.equalTo(45)
        }
        
        
    }
    @objc private func showMainTabBarViewController(){
        NSNotificationCenter.defaultCenter().postNotificationName(showMainTabBarViewControllerNotification, object: nil)
        
        
    }
    /// 懒加载开始按钮
    private lazy var startBtn: UIButton = {
       let btn = UIButton()
        btn.setTitle("开始小日子", forState: UIControlState.Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
        btn.setBackgroundImage(UIImage(named: "into_home"), forState: UIControlState.Normal)
        btn.addTarget(self, action: "showMainTabBarViewController", forControlEvents: UIControlEvents.TouchUpInside)
        return btn
    }()
   /// 引导页的大背景图片
   private lazy var backgroundImage: UIImageView = {
        let img = UIImageView(frame: MainBounds)
    var imgPath: String?
    switch AppWidth {
    case 375: imgPath = NSBundle.mainBundle().pathForResource("fourpage-375w-667h@2x.jpg", ofType: nil)
    case 414: imgPath = NSBundle.mainBundle().pathForResource("fourpage-414w-736h@3x.jpg", ofType: nil)
    case 568: imgPath = NSBundle.mainBundle().pathForResource("fourpage-568h@2x.jpg", ofType: nil)
        
    default: imgPath = NSBundle.mainBundle().pathForResource("fourpage@2x.jpg", ofType: nil)
    }
    img.image = UIImage(contentsOfFile: imgPath!)
           return img
    }()
}
